<?php 
	 if (isset($_POST["submit"])){
		$player1_score1 =$_POST['player1_score1'];
		$player2_score1 =$_POST['player2_score1'];
		$player1_score2 =$_POST['player1_score2'];
		$player2_score2 =$_POST['player2_score2'];
		$player1_score3 =$_POST['player1_score3'];
		$player2_score3 =$_POST['player2_score3'];
		$matchID =$_POST['matchID'];
		
		$team1Points=array(
		$_POST['team1Points0'],
		$_POST['team1Points1'],
		$_POST['team1Points2'],
		$_POST['team1Points3'],
		$_POST['team1Points4'],
		$_POST['team1Points5']);
		$team2Points=array(
		$_POST['team2Points0'],
		$_POST['team2Points1'],
		$_POST['team2Points2'],
		$_POST['team2Points3'],
		$_POST['team2Points4'],
		$_POST['team2Points5']);
		

		$roundSchedule=$_POST['roundSchedule'];
		
										
		if (($player1_score1>=0)&&($player2_score1>=0)){
			if ($repGame->readGame($matchID,1)!=""){
				$repGame->updateGame($matchID,1,$player1_score1,$player2_score1);
			}
			else{
				$repGame->createGame($matchID,1,$player1_score1,$player2_score1);
			}
		}
		if (($player1_score2>=0)&&($player2_score2>=0)){
			if ($repGame->readGame($matchID,2)!=""){
				$repGame->updateGame($matchID,2,$player1_score2,$player2_score2);
			}
			else{
				$repGame->createGame($matchID,2,$player1_score2,$player2_score2);
			}
		}
		if (($player1_score3>=0)&&($player2_score3>=0)){
			if ($repGame->readGame($matchID,3)!=""){
				$repGame->updateGame($matchID,3,$player1_score3,$player2_score3);
			}
			else{
				$repGame->createGame($matchID,3,$player1_score3,$player2_score3);
			}
		}
		
		for ($j=0; $j<6; $j++){	
			
			if (($team1Points[$j]>=0)&&($team2Points[$j]>=0)){
				
				if (count($repDoubles->getDoublesByScheduleIDAndGameNo($roundSchedule,$j+1))!=0){
					$repDoubles->updateDoubles($roundSchedule,$j+1,$team1Points[$j],$team2Points[$j]);
				}
				else{
					$repDoubles->createDoubles($roundSchedule,$j+1,$team1Points[$j],$team2Points[$j]);
					
				}
			}	
		
		}			
	}
 ?>